package com.example.zselasticsearchsf.controller;

import com.example.zselasticsearchsf.dto.SfwDto;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: Steven
 * @Date: 2021/10/18 8:37
 */
@Controller
public class RoutController {

    @GetMapping({"/","/search"})
    public String getIndex(){
        return "search_all";
    }

    @GetMapping({"/wall"})
    public String wall(){
        return "wall";
    }

    @GetMapping("/Detail")
    public String getIDetail(@RequestParam(value = "dbID",required = false) String dbID,
                           @RequestParam(value = "dbName",required = false) String dbName,
                           @RequestParam(value = "sysID",required = false) String sysID){
        return "detail";
    }

    @GetMapping("/s")
    public String getIDetail(){
        return "search";
    }

    @GetMapping("/Test")
    public String Test(@RequestParam(value = "dbID",required = false) String dbID,
                             @RequestParam(value = "dbName",required = false) String dbName,
                             @RequestParam(value = "sysID",required = false) String sysID){
        return "test";
    }

    @GetMapping("/t")
    public String t(@RequestParam(value = "dbID",required = false) String dbID,
                       @RequestParam(value = "dbName",required = false) String dbName,
                       @RequestParam(value = "sysID",required = false) String sysID){
        return "t";
    }

    @GetMapping({"/1","/index"})
    public ModelAndView  getIndex1(Model model){
        SfwDto sfwDto = new SfwDto();
        sfwDto.setCaseTittlDateUtilse("1王某甲申请办理居住权合同公证案");
        sfwDto.setNumber("123cccccc");
        sfwDto.setCaseUrl("http://www.baidu.com");
        sfwDto.setSubmissionTime("2021-10-09");
        sfwDto.setCaseType("公证业务案例");
        sfwDto.setVisits(111);


        SfwDto sfwDto1 = new SfwDto();
        sfwDto1.setCaseTittlDateUtilse("1王某甲申请办理居住权合同公证案");
        sfwDto1.setNumber("123ccccccXXXX");
        sfwDto1.setCaseUrl("http://www.aiqiyi.com");
        sfwDto1.setSubmissionTime("2021-10-05");
        sfwDto1.setCaseType("公证业务案例222");
        sfwDto1.setVisits(131114);

        List<SfwDto> getUserlist= Arrays.asList(sfwDto,sfwDto1);
        model.addAttribute("userList", getUserlist);
        model.addAttribute("title", "用户管理");
        return new ModelAndView("users/list", "userModel", model);
    }

    @GetMapping("/f")
    public String  getFooter(Model model){
        return "fragments/footer";
    }
    @GetMapping("/bb")
    public String  www(Model model){
        return "222";
    }

    @GetMapping("/movie")
    public String  movie( ){
        return "movie";
    }
}
